package com.qst.action.user;

import com.qst.BaseServlet;
import com.qst.ExamException;
import com.qst.WebUtil;
import com.qst.entity.Team;
import com.qst.service.TeamService;
import com.qst.service.impl.ServiceFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

//@WebServlet("/user/showReg.do")
public class ShowRegServlet extends BaseServlet {
    private TeamService classTeamService = ServiceFactory
            .getService(TeamService.class);

    @Override
    protected void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            List<Team> teamList = classTeamService.findAll();
            req.setAttribute("teamList", teamList);
            WebUtil.forward(req, resp, "/user/reg.jsp");
        } catch (ExamException ex) {

            addError(req, ex.getMessage());
        }
    }
}
